import { GetListsAsync,GetById } from '@/services/article';

const ArticleModel = {
    namespace: 'Article',
    state: {
        current: {},
        response: {},
    },
    effects: {
        * getListsAsync({ payload }, { call, put }) {
            const response = yield call(GetListsAsync, payload);
            yield put({
                type: 'deal',
                payload: response,
            });
        },
        * getById({ payload }, { call, put }) {
            const response = yield call(GetById, payload);
            yield put({
                type: 'deal',
                payload: response,
            });
        },
        * setCurrent({ payload }, { put }) {
            yield put({
                type: 'set',
                payload,
            });
        },
    },
    reducers: {
        set(state, action) {
            return { ...state, current: action.payload };
        },
        deal(state, action) {
            return { ...state, response: action.payload };
        },
    },
};
export default ArticleModel;